package edu.scu.declaresys.vo;

import java.util.Date;

import edu.scu.declaresys.dao.util.Column;
import edu.scu.declaresys.dao.util.FieldWalker;
import edu.scu.declaresys.dao.util.Table;

/**
 * 
 * @author: zt
 * @since : 2013-7-2
 */
@Table(code=Msg.T_TABLE)
public class Msg implements java.io.Serializable
{
	private static final long	serialVersionUID	= -6420066912748945306L;
	//
	// table column name.
	//
	public static final String	T_TABLE					= "msg";
	public static final String	T_ID					= "id";
	public static final String	T_MSG_CLASS_ID			= "msgClassId";
	public static final String	T_FROM_USER_ID			= "fromUserId";
	public static final String	T_TO_CITY_USER_ID		= "toCityUserId";
	public static final String	T_TO_PROVINCE_USER_ID	= "toProvinceUserId";
	public static final String	T_TITLE					= "title";
	public static final String	T_CONTENT				= "content";
	public static final String	T_SEND_TIME				= "sendTime";
	public static final String	T_HAS_READ				= "hasRead";
	//
	// Fields
	//
	@Column(code=T_ID)
	private Integer	id;
	
	@Column(code=T_MSG_CLASS_ID)
	private Integer	msgClassId;
	
	@Column(code=T_FROM_USER_ID)
	private Integer	fromUserId;
	
	@Column(code=T_TO_CITY_USER_ID)
	private Integer	toCityUserId;
	
	@Column(code=T_TO_PROVINCE_USER_ID)
	private Integer	toProvinceUserId;
	
	@Column(code=T_TITLE)
	private String	title;
	
	@Column(code=T_CONTENT)
	private String	content;
	
	@Column(code=T_SEND_TIME)
	private Date	sendTime;
	
	@Column(code=T_HAS_READ)
	private Boolean	hasRead;
	//
	// References
	//
	private MsgClass msgClass;
	private User fromUser;
	private User toCityUser;
	private User toProvinceuser;
	//
	// Constructors
	//
	/** default constructor */
	public Msg()
	{
	}
	
	/** full constructor */
	public Msg(Integer msgClassId, Integer fromUserId, Integer toCityUserId,
			Integer toProvinceUserId, String title, String content,
			Date sendTime, boolean hasRead)
	{
		this.msgClassId = msgClassId;
		this.fromUserId = fromUserId;
		this.toCityUserId = toCityUserId;
		this.toProvinceUserId = toProvinceUserId;
		this.title = title;
		this.content = content;
		this.sendTime = sendTime;
		this.hasRead = hasRead;
	}
	//
	// Override functions.
	//
	public String toString()
	{
		return FieldWalker.makeNonstaticFields(this, FieldWalker.WITHOUT_NULL);
	}
	
	@Override
	public int hashCode()
	{
		return id.hashCode();
	}

	@Override
	public boolean equals(Object obj)
	{
		if(this == obj)
		{
			return true;
		}
		if(obj == null)
		{
			return false;
		}
		if(!(obj instanceof Msg))
		{
			return false;
		}
		//
		return this.id.equals(((Msg)obj).id);
	}
	
	//
	// Getters and Setters
	//
	public Integer getId()
	{
		return this.id;
	}
	
	public void setId(Integer id)
	{
		this.id = id;
	}
	
	public Integer getMsgClassId()
	{
		return this.msgClassId;
	}
	
	public void setMsgClassId(Integer msgClassId)
	{
		this.msgClassId = msgClassId;
	}
	
	public Integer getFromUserId()
	{
		return this.fromUserId;
	}
	
	public void setFromUserId(Integer fromUserId)
	{
		this.fromUserId = fromUserId;
	}
	
	public Integer getToCityUserId()
	{
		return this.toCityUserId;
	}
	
	public void setToCityUserId(Integer toCityUserId)
	{
		this.toCityUserId = toCityUserId;
	}
	
	public Integer getToProvinceUserId()
	{
		return this.toProvinceUserId;
	}
	
	public void setToProvinceUserId(Integer toProvinceUserId)
	{
		this.toProvinceUserId = toProvinceUserId;
	}
	
	public String getTitle()
	{
		return this.title;
	}
	
	public void setTitle(String title)
	{
		this.title = title;
	}
	
	public String getContent()
	{
		return this.content;
	}
	
	public void setContent(String content)
	{
		this.content = content;
	}
	
	public Date getSendTime()
	{
		return this.sendTime;
	}
	
	public void setSendTime(Date sendTime)
	{
		this.sendTime = sendTime;
	}
	
	public Boolean getHasRead()
	{
		return this.hasRead;
	}
	
	public void setHasRead(Boolean hasRead)
	{
		this.hasRead = hasRead;
	}

	public MsgClass getMsgClass()
	{
		return msgClass;
	}

	public void setMsgClass(MsgClass msgClass)
	{
		this.msgClass = msgClass;
	}

	public User getFromUser()
	{
		return fromUser;
	}

	public void setFromUser(User fromUser)
	{
		this.fromUser = fromUser;
	}

	public User getToCityUser()
	{
		return toCityUser;
	}

	public void setToCityUser(User toCityUser)
	{
		this.toCityUser = toCityUser;
	}

	public User getToProvinceuser()
	{
		return toProvinceuser;
	}

	public void setToProvinceuser(User toProvinceuser)
	{
		this.toProvinceuser = toProvinceuser;
	}
	
}
